package com.FrameWork.Entity;

import java.io.Serializable;

import android.app.Activity;

public class VisitTypeEntity implements Serializable 
{
	public static final String ID		= "ID";
	public static final String CONFIG	    = "CONFIG";
	public static final String Description       = "Description";

	public static final String CustomerInfo      = "CustomerInfo";
	public static final String FinishVisit       = "FinishVisit";

	public static final String CollectAsset      = "CollectAsset";
	public static final String CollectKPI	= "CollectKPI";
	public static final String CollectOrder      = "CollectOrder";
	public static final String CollectStorage    = "CollectStorage";
	public static final String ScanBarCode       = "ScanBarCode";
	public static final String ScanRFID	  = "ScanRFID";
	public static final String CancelModel       = "CancelModel";
	public static final String CollectGPS	= "CollectGPS";
	public static final String FailNeedPhoto     = "FailNeedPhoto";
	public static final String NeedChain	 = "NeedChain";
	public static final String NeedPhoto	 = "NeedPhoto";
	public static final String ConfigData	= "ConfigData";
	public static final String CollectCPR	= "CollectCPR";

	/**
	 * 采集资产
	 */
	public boolean	     isCollectAsset;
	/**
	 * 采集KPI
	 */
	public boolean	     isCollectKPI;
	/**
	 * 采集订单
	 */
	public boolean	     isCollectOrder;
	/**
	 * 采集库存
	 */
	public boolean	     isCollectStorage;
	/**
	 * 扫描条码
	 */
	public boolean	     isScanBarCode;
	/**
	 * 扫描RFID
	 */
	public boolean	     isScanRFID;
	/**
	 * 取消模式
	 */
	public boolean	     isCancelModel;
	/**
	 * 采集GPS
	 */
	public boolean	     isCollectGPS;
	/**
	 * 异常情况需要拍照
	 */
	public boolean	     isFailNeedPhoto;
	/**
	 * 采集订单需要经销商
	 */
	public boolean	     isNeedChain;
	/**
	 * 需要拍照
	 */
	public boolean	     isNeedPhoto;
	/**
	 * 配置数据
	 */
	public boolean	     isConfigData;
	/**
	 * 采集CPR
	 */
	public boolean	     isCollectCPR;
	/**
	 * GPS超时（s）
	 */
	public int	      CollectGPSTime;

	/**
	 * 转换CONFIG到VisitTasks对象。
	 * 
	 * <pre>
	 * CONFIG：'1|1|1|0|0|0|0|1|1|1|1|1|1|10'
	 * 0|采集资产
	 * 1|采集KPI
	 * 2|采集订单
	 * 3|采集库存
	 * 4|扫描条码
	 * 5|扫描RFID
	 * 6|取消模式
	 * 7|采集GPS
	 * 8|异常情况需要拍照
	 * 9|采集订单需要经销商
	 * 10|需要拍照
	 * 11|配置数据
	 * 12|采集CPR
	 * 13|GPS超时
	 * </pre>
	 */
	public static VisitTypeEntity parseConfig(String config)
	{
		VisitTypeEntity visitTaskEntity = new VisitTypeEntity();
		String[] configs = config.split("\\|");
		for (int i = 0; i < configs.length; i++)
		{
			boolean isTrue = configs[i].equals("1");
			switch (i)
			{
			case 0:
				visitTaskEntity.isCollectAsset = isTrue;
				break;
			case 1:
				visitTaskEntity.isCollectKPI = isTrue;
				break;
			case 2:
				visitTaskEntity.isCollectOrder = isTrue;
				break;
			case 3:
				visitTaskEntity.isCollectStorage = isTrue;
				break;
			case 4:
				visitTaskEntity.isScanBarCode = isTrue;
				break;
			case 5:
				visitTaskEntity.isScanRFID = isTrue;
				break;
			case 6:
				visitTaskEntity.isCancelModel = isTrue;
				break;
			case 7:
				visitTaskEntity.isCollectGPS = isTrue;
				break;
			case 8:
				visitTaskEntity.isFailNeedPhoto = isTrue;
				break;
			case 9:
				visitTaskEntity.isNeedChain = isTrue;
				break;
			case 10:
				visitTaskEntity.isNeedPhoto = isTrue;
				break;
			case 11:
				visitTaskEntity.isConfigData = isTrue;
				break;
			case 12:
				visitTaskEntity.isCollectCPR = isTrue;
				break;
			case 13:
				try
				{
					visitTaskEntity.CollectGPSTime = Integer.parseInt(configs[i]);
				}
				catch(Exception err)
				{
					visitTaskEntity.CollectGPSTime=5;
				}
				break;
			default:
				break;
			}
		}
		return visitTaskEntity;
	}

}
